Replication material for 

“Thin-skinned Leaders: Regime Legitimation, Protest Issues and Repression in Autocracies” 

by Eda Keremoglu, Sebastian Hellmeier, Nils B. Weidmann

forthcoming in Political Science Research and Methods.

This folder contains data and code required to replicate all tables and figures in the main article and online supplementary material.

The main analyses are carried out in R. The SEM analysis is executed in Stata.

Please direct inquiries to Eda Keremoglu (eda.keremoglu-waibler@uni-konstanz.de).

R files: 

* file "Replication_Keremoglu_etal_PSRM.Rproj" is the R project for the replication analysis.
* file "analysis.Rmd": contains the code to replicate all tables and figures. It loads the datasets below.
* file "data.Rda": this is the main dataset used in the analysis.
* file "vdem_claims.Rda": contains V-Dem data on legitimacy claims for Figure 1 and Figure A.1. This is loaded separately because its time frame extends the one of the MMAD event data and our main analyses.
* file "model.Rds" loads the BTM model separately for Figure 2.
* file "interaction_plot.R" loads a modified function to plot the interaction effects.

.csv files: 

* file "summary_BTM.csv": contains summary information from the BTM topic model for Table 1.
* file "summary_LDA.csv": contains summary information from the LDA topic model for Table A.1 and Table A.2.

The following files contain data and code necessary to build the final dataset "data.Rda":

* file "data_preparation.Rmd": contains the code to run the topic models and builds the final dataset "data.Rda". The script loads "mmad_events.Rda" and "leg_cov_data.Rda" (see below for details). It also generates the datasets necessary for the SEM analysis in Stata (see below).
* file "mmad_events.Rda": contains all anti-government protest events in the Mass Mobilization in Autocracies Database (MMAD).
* file "leg_cov_data.Rda": contains V-Dem data on legitimacy claims and all other country-level covariates as described in the manuscript.


Stata files for SEM replication only:

* file "data_subset_leader_ord.dta": contains sample of events with strong leader claims.
* file "data_subset_noleader_ord.dta": contains sample of events with weak leader claims.
* file "replication_stata_A8.do": contains Stata do-file to replicate Table A.8 and Figure A.8 in the Appendix.

Log files in R and Stata:

* file "data_preparation.html" contains the output of the "data_preparations" script. 
* file "analysis.html" contains the output of the "analysis" script. 
* file "replication_stata_A8.log" contains the log files of the Stata do-file. 


R session info:

R version 3.6.1 (2019-07-05)Platform: x86_64-apple-darwin15.6.0 (64-bit)Running under: macOS Catalina 10.15.7Matrix products: defaultBLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylibLAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dyliblocale:[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8attached base packages:[1] parallel  stats     graphics  grDevices utils     datasets  methods   base     other attached packages: [1] xtable_1.8-4       sandwich_3.0-0     lmtest_0.9-38      zoo_1.8-8          stargazer_5.2.2    multiwayvcov_1.2.3 [7] lubridate_1.7.9    survival_3.2-3     countrycode_1.2.0  haven_2.2.0        boRingTrees_0.02   data.table_1.12.8 [13] textmineR_3.0.4    Matrix_1.2-17      BTM_0.2.1          quanteda_1.5.1     stringi_1.5.3      forcats_0.5.0     [19] stringr_1.4.0      dplyr_1.0.2        purrr_0.3.4        readr_1.3.1        tidyr_1.1.2        tibble_3.0.4      [25] ggplot2_3.3.2      tidyverse_1.3.0   loaded via a namespace (and not attached): [1] nlme_3.1-140         matrixStats_0.55.0   fs_1.4.1             httr_1.4.2           rstan_2.19.2         [6] SnowballC_0.6.0      tools_3.6.1          backports_1.1.10     R6_2.5.0             DBI_1.1.0           [11] colorspace_1.4-1     withr_2.3.0          tidyselect_1.1.0     gridExtra_2.3        prettyunits_1.1.1   [16] mnormt_1.5-5         processx_3.4.4       compiler_3.6.1       cli_2.2.0            rvest_0.3.6         [21] lgr_0.3.4            xml2_1.3.2           rsparse_0.4.0        labeling_0.4.2       scales_1.1.1.9000   [26] psych_1.8.12         callr_3.5.1          digest_0.6.27        StanHeaders_2.21.0-1 foreign_0.8-71      [31] rmarkdown_2.5        RhpcBLASctl_0.20-137 pkgconfig_2.0.3      htmltools_0.5.0      dbplyr_1.4.3        [36] rlang_0.4.8          readxl_1.3.1         rstudioapi_0.13      farver_2.0.3         generics_0.1.0      [41] jsonlite_1.7.1       inline_0.3.15        magrittr_2.0.1       text2vec_0.6         loo_2.2.0           [46] Rcpp_1.0.5           munsell_0.5.0        RcppProgress_0.4.2   fansi_0.4.1          lifecycle_0.2.0     [51] yaml_2.2.1           pkgbuild_1.1.0       grid_3.6.1           mlapi_0.1.0          crayon_1.3.4        [56] lattice_0.20-38      splines_3.6.1        hms_0.5.3            knitr_1.29           ps_1.4.0            [61] pillar_1.4.6         boot_1.3-22          stopwords_1.0        stats4_3.6.1         fastmatch_1.1-0     [66] reprex_0.3.0         glue_1.4.2           evaluate_0.14        RcppParallel_4.4.3   modelr_0.1.8        [71] float_0.2-4          vctrs_0.3.4          cellranger_1.1.0     gtable_0.3.0         assertthat_0.2.1    [76] xfun_0.19            broom_0.7.2          spacyr_1.2           ellipsis_0.3.1   
